package com.example.tfliteonwatch;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.nio.ByteBuffer;

public class testResult extends AppCompatActivity {

    private TextView text; //“第i次的记录”
    private TextView accuracy;
    private TextView delay;
    private TextView activity;
    private Button result_conform;
    private Button trainbutton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        para.sensorID++;
        para.firstwrite=0;
        setContentView(R.layout.activity_test_result);
        text=(TextView) findViewById(R.id.text) ;
        text.setText("第"+para.setTimeIndex+"/"+para.action.size()+"个动作");

        activity=(TextView) findViewById(R.id.activity) ;
        activity.setText("活动："+para.action.get(para.setTimeIndex-1));

        accuracy=(TextView) findViewById(R.id.accuracy) ;
        delay = (TextView) findViewById(R.id.delay);
        trainbutton=(Button) findViewById(R.id.train);
        trainbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                    Intent intent=new Intent(testResult.this, training.class);
                    startActivity(intent);


            }
        });
        result_conform=(Button) findViewById(R.id.result_confirm);
        result_conform.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                testing.acclist.clear();
                testing.grylist.clear();
                Log.d("",para.setTimeIndex+" "+para.action.size());
                if(para.setTimeIndex!=para.action.size()){   //动作未测量完全
                    Intent intent=new Intent(testResult.this, testing.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }
                else {                           //动作测量完
                    Intent intent=new Intent(testResult.this, testFinish.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }
            }
        });
        while(true) {
            if(para.calculate==0) {
                accuracy.setText("精度：");
                delay.setText("时延：");
            }
            else{

                accuracy.setText("精度："+para.accuracy);
                delay.setText("时延："+para.delay);
                break;
            }
        }



    }
}